A variety of icon fixes for Mapsource, Mapsend, and PCX from Ian Mahuron.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 21 May 2003 20:03:32 +0000 (20:03 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 21 May 2003 20:03:32 +0000 (20:03 +0000)
gpsbabel/Makefile
gpsbabel/garmin.c
gpsbabel/garmin_tables.h [new file with mode: 0644]
gpsbabel/mapsource.c
gpsbabel/pcx.c

index d38a62f2f613b597840eb7b237af9cb44a50790e..7f960583d384c1a6a3d39c3654f4c25fb0621d71 100644 (file)
@@ -52,7 +52,7 @@ leaktest:
 
 dep:
        make clean && make CC="gcc -MMD"  && cat *.d */*.d > /tmp/dep && rm *.d */*.d
-       (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e "\t./mkstyle.sh > internal_styles.c" ) >> /tmp/dep
+       (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e "\t./mkstyle.sh > $@ || (rm -f $@ ; exit 1)" ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
 VERSIONU=1_1_1_beta00514003
@@ -74,12 +74,14 @@ cetus.o: cetus.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 copilot.o: copilot.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 csv_util.o: csv_util.c defs.h queue.h csv_util.h
 duplicate.o: duplicate.c defs.h queue.h
+easygps.o: easygps.c defs.h queue.h
 filter_vecs.o: filter_vecs.c defs.h queue.h
 garmin.o: garmin.c defs.h queue.h jeeps/gps.h jeeps/gpsport.h \
   jeeps/gpsserial.h jeeps/gpssend.h jeeps/gpsread.h jeeps/gpsutil.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsnmea.h jeeps/gpsmem.h jeeps/gpsrqst.h \
-  jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h
+  jeeps/gpsinput.h jeeps/gpsproj.h jeeps/gpsnmeafmt.h jeeps/gpsnmeaget.h \
+  garmin_tables.h
 gcdb.o: gcdb.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 geo.o: geo.c defs.h queue.h
 gpspilot.o: gpspilot.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
@@ -91,9 +93,9 @@ magnav.o: magnav.c defs.h queue.h coldsync/palm.h coldsync/pdb.h
 magproto.o: magproto.c defs.h queue.h magellan.h
 main.o: main.c defs.h queue.h
 mapsend.o: mapsend.c defs.h queue.h mapsend.h magellan.h
-mapsource.o: mapsource.c defs.h queue.h
+mapsource.o: mapsource.c defs.h queue.h garmin_tables.h
 mkshort.o: mkshort.c defs.h queue.h
-pcx.o: pcx.c defs.h queue.h
+pcx.o: pcx.c defs.h queue.h garmin_tables.h
 position.o: position.c defs.h queue.h
 psp.o: psp.c defs.h queue.h
 queue.o: queue.c queue.h
index 41e12d74c9e561ea458cec0ef3d7f14ddcb1acd0..9442d8a9bb9db1deb86f277aeb34d00144fa7035 100644 (file)
 #include <limits.h>
 #include "defs.h"
 #include "jeeps/gps.h"
+#include "garmin_tables.h"
 
 #define MYNAME "GARMIN" 
 static const char *portname;
 static void *mkshort_handle;
-extern const char *mps_find_desc_from_icon_number(const int icon);
 
 static void
 rw_init(const char *fname, const char *opts)
@@ -78,7 +78,7 @@ waypt_read(void)
                wpt_tmp->position.longitude.degrees = way[i]->lon;
                wpt_tmp->position.latitude.degrees = way[i]->lat;
                wpt_tmp->icon_descr =
-                       mps_find_desc_from_icon_number(way[i]->smbl);
+                       mps_find_desc_from_icon_number(way[i]->smbl, PCX);
                /*
                 * If a unit doesn't store altitude info (i.e. a D103)
                 * gpsmem will default the alt to INT_MAX.   Other units 
@@ -265,7 +265,7 @@ data_write(void)
                }
                way[i]->lon = wpt->position.longitude.degrees;
                way[i]->lat = wpt->position.latitude.degrees;
-               way[i]->smbl = mps_find_icon_number_from_desc(wpt->icon_descr);
+               way[i]->smbl = mps_find_icon_number_from_desc(wpt->icon_descr, PCX);
                if (wpt->position.altitude.altitude_meters != unknown_alt) {
                        way[i]->alt = wpt->position.altitude.altitude_meters;
                }
diff --git a/gpsbabel/garmin_tables.h b/gpsbabel/garmin_tables.h
new file mode 100644 (file)
index 0000000..a90fe5e
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+    Garmin icon tables
+    Based on information provided by Ian Cowley, Sigurd Humerfelt,
+       and Garmin MapSource
+
+    Copyright (C) 2003 Robert Lipe, robertlipe@usa.net
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+ */
+
+typedef struct icon_mapping {
+       const int mpssymnum;
+       const int pcxsymnum;
+       const char *icon;
+} icon_mapping_t;
+
+typedef enum {MAPSOURCE, PCX, GARMIN_SERIAL} garmin_formats_e;
+
+extern const 
+char *mps_find_desc_from_icon_number(const int icon, 
+       garmin_formats_e garmin_format);
+
+/* MapSource 4.13 */
+static icon_mapping_t icon_table[] = {
+/*       mps    pcx    desc */
+       {   107, 16384, "Airport" },
+       {    73,  8204, "Amusement Park" },
+       {    55,   169, "Ball Park" },
+       {     6,     6, "Bank" },
+       {    13,    13, "Bar" },
+       {   104,  8244, "Beach" },
+       {     1,     1, "Bell" },
+       {    37,   150, "Boat Ramp" },
+       {    74,  8205, "Bowling" },
+       {    93,  8233, "Bridge" },
+       {    94,  8234, "Building" },
+       {    38,   151, "Campground" },
+       {    56,   170, "Car" },
+       {    75,  8206, "Car Rental" },
+       {    76,  8207, "Car Repair" },
+       {    95,  8235, "Cemetery" },
+       {    96,  8236, "Church" },
+       {    65,   179, "Circle with X" },
+       {    72,  8203, "City (Capitol)" },
+       {    71,  8200, "City (Large)" },
+       {    70,  8199, "City (Medium)" },
+       {    69,  8198, "City (Small)" },
+       {    97,  8237, "Civil" },
+       {   119,  8262, "Contact, Afro" },
+       {   120,  8272, "Contact, Alien" },
+       {   121,  8258, "Contact, Ball Cap" },
+       {   122,  8259, "Contact, Big Ears" },
+       {   123,  8271, "Contact, Biker" },
+       {   124,  8273, "Contact, Bug" },
+       {   125,  8274, "Contact, Cat" },
+       {   126,  8275, "Contact, Dog" },
+       {   127,  8263, "Contact, Dreadlocks" },
+       {   128,  8264, "Contact, Female1" },
+       {   129,  8265, "Contact, Female2" },
+       {   130,  8266, "Contact, Female3" },
+       {   131,  8261, "Contact, Goatee" },
+       {   132,  8268, "Contact, Kung-Fu" },
+       {   133,  8276, "Contact, Pig" },
+       {   134,  8270, "Contact, Pirate" },
+       {   135,  8267, "Contact, Ranger" },
+       {   136,  8257, "Contact, Smiley" },
+       {   137,  8260, "Contact, Spike" },
+       {   138,  8269, "Contact, Sumo" },
+       {    52,   165, "Controlled Area" },
+       {    89,  8220, "Convenience Store" },
+       {    98,  8238, "Crossing" },
+       {    51,   164, "Dam" },
+       {    53,   166, "Danger Area" },
+       {    87,  8218, "Department Store" },
+       {     4,     4, "Diver Down Flag 1" },
+       {     5,     5, "Diver Down Flag 2" },
+       {    41,   154, "Drinking Water" },
+       {    63,   177, "Exit" },
+       {    77,  8208, "Fast Food" },
+       {     7,     7, "Fishing Area" },
+       {    78,  8209, "Fitness Center" },
+       {    64,   178, "Flag" },
+       {   105,  8245, "Forest" },
+       {     8,     8, "Gas Station" },
+       {   117,  8255, "Geocache" },
+       {   118,  8256, "Geocache Found" },
+       {    99,  8239, "Ghost Town" },
+       {   113, 16393, "Glider Area" },
+       {    68,  8197, "Golf Course" },
+       {     2,     2, "Green Diamond" },
+       {    15,    15, "Green Square" },
+       {   108, 16388, "Heliport" },
+       {     9,     9, "Horn" },
+       {    57,   171, "Hunting Area" },
+       {    44,   157, "Information" },
+       {   100,  8240, "Levee" },
+       {    12,    12, "Light" },
+       {    90,  8221, "Live Theater" },
+       {    59,   173, "Lodging" },
+       {    20,    21, "Man Overboard" },
+       {     0,     0, "Marina" },
+       {    43,   156, "Medical Facility" },
+       {    66,  8195, "Mile Marker" },
+       {   101,  8241, "Military" },
+       {    60,   174, "Mine" },
+       {    79,  8210, "Movie Theater" },
+       {    80,  8211, "Museum" },
+       {    21,    22, "Navaid, Amber" },
+       {    22,    23, "Navaid, Black" },
+       {    23,    24, "Navaid, Blue" },
+       {    24,    25, "Navaid, Green" },
+       {    25,    26, "Navaid, Green/Red" },
+       {    26,    27, "Navaid, Green/White" },
+       {    27,    28, "Navaid, Orange" },
+       {    28,    29, "Navaid, Red" },
+       {    29,    30, "Navaid, Red/Green" },
+       {    30,    31, "Navaid, Red/White" },
+       {    31,    32, "Navaid, Violet" },
+       {    32,    33, "Navaid, White" },
+       {    33,    34, "Navaid, White/Green" },
+       {    34,    35, "Navaid, White/Red" },
+       {   102,  8242, "Oil Field" },
+       {   115, 16395, "Parachute Area" },
+       {    46,   159, "Park" },
+       {    45,   158, "Parking Area" },
+       {    81,  8212, "Pharmacy" },
+       {    47,   160, "Picnic Area" },
+       {    82,  8213, "Pizza" },
+       {    83,  8214, "Post Office" },
+       {   109, 16389, "Private Field" },
+       {    36,    37, "Radio Beacon" },
+       {     3,     3, "Red Diamond" },
+       {    16,    16, "Red Square" },
+       {    10,    10, "Residence" },
+       {    11,    11, "Restaurant" },
+       {    54,   167, "Restricted Area" },
+       {    39,   152, "Restroom" },
+       {    84,  8215, "RV Park" },
+       {    91,  8226, "Scales" },
+       {    48,   161, "Scenic Area" },
+       {    85,  8216, "School" },
+       {   116, 16402, "Seaplane Base" },
+       {    19,    19, "Shipwreck" },
+       {    58,   172, "Shopping Center" },
+       {   112, 16392, "Short Tower" },
+       {    40,   153, "Shower" },
+       {    49,   162, "Skiing Area" },
+       {    14,    14, "Skull and Crossbones" },
+       {   110, 16390, "Soft Field" },
+       {    86,  8217, "Stadium" },
+       {   106,  8246, "Summit" },
+       {    50,   163, "Swimming Area" },
+       {   111, 16391, "Tall Tower" },
+       {    42,   155, "Telephone" },
+       {    92,  8227, "Toll Booth" },
+       {    67,  8196, "TracBack Point" },
+       {    61,   175, "Trail Head" },
+       {    62,   176, "Truck Stop" },
+       {   103,  8243, "Tunnel" },
+       {   114, 16394, "Ultralight Area" },
+       {    18,    18, "Waypoint" },
+       {    17,    17, "White Buoy" },
+       {    35,    36, "White Dot" },
+       {    88,  8219, "Zoo" },
+       {    -1,    -1, NULL },
+};
index 5703bd42e8c5377819afbc3a985dd0bed87d8137..29b586320294e52fcd0c28c0061f6455df943bac 100644 (file)
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "defs.h"
+#include "garmin_tables.h"
 #include <ctype.h>
 
 static FILE *mps_file_in;
@@ -47,154 +48,6 @@ char mps_ftr[] = {
        0x02, 0x00, 0x00, 0x00, 0x56, 0x00, 0x01
 };
 
-typedef struct icon_mapping {
-       const int symnum;
-       const char *icon;
-} icon_mapping_t;
-
-static icon_mapping_t icon_table[] = {
-       {   107, "Airport" },
-       {    73, "Amusement Park" },
-       {    55, "Ball Park" },
-       {     6, "Bank" },
-       {    13, "Bar" },
-       {   104, "Beach" },
-       {     1, "Bell" },
-       {    37, "Boat Ramp" },
-       {    74, "Bowling" },
-       {    93, "Bridge" },
-       {    94, "Building" },
-       {    38, "Campground" },
-       {    56, "Car" },
-       {    75, "Car Rental" },
-       {    76, "Car Repair" },
-       {    95, "Cemetery" },
-       {    96, "Church" },
-       {    65, "Circle with X" },
-       {    72, "City (Capitol)" },
-       {    71, "City (Large)" },
-       {    70, "City (Medium)" },
-       {    69, "City (Small)" },
-       {    97, "Civil" },
-       {   119, "Contact, Afro" },
-       {   120, "Contact, Alien" },
-       {   121, "Contact, Ball Cap" },
-       {   122, "Contact, Big Ears" },
-       {   123, "Contact, Biker" },
-       {   124, "Contact, Bug" },
-       {   125, "Contact, Cat" },
-       {   126, "Contact, Dog" },
-       {   127, "Contact, Dreadlocks" },
-       {   128, "Contact, Female1" },
-       {   129, "Contact, Female2" },
-       {   130, "Contact, Female3" },
-       {   131, "Contact, Goatee" },
-       {   132, "Contact, Kung-Fu" },
-       {   133, "Contact, Pig" },
-       {   134, "Contact, Pirate" },
-       {   135, "Contact, Ranger" },
-       {   136, "Contact, Smiley" },
-       {   137, "Contact, Spike" },
-       {   138, "Contact, Sumo" },
-       {    52, "Controlled Area" },
-       {    89, "Convenience Store" },
-       {    98, "Crossing" },
-       {    51, "Dam" },
-       {    53, "Danger Area" },
-       {    87, "Department Store" },
-       {     4, "Diver Down Flag 1" },
-       {     5, "Diver Down Flag 2" },
-       {    41, "Drinking Water" },
-       {    63, "Exit" },
-       {    77, "Fast Food" },
-       {     7, "Fishing Area" },
-       {    78, "Fitness Center" },
-       {    64, "Flag" },
-       {   105, "Forest" },
-       {     8, "Gas Station" },
-       {   117, "Geocache" },
-       {   118, "Geocache Found" },
-       {    99, "Ghost Town" },
-       {   113, "Glider Area" },
-       {    68, "Golf Course" },
-       {     2, "Green Diamond" },
-       {    15, "Green Square" },
-       {   108, "Heliport" },
-       {     9, "Horn" },
-       {    57, "Hunting Area" },
-       {    44, "Information" },
-       {   100, "Levee" },
-       {    12, "Light" },
-       {    90, "Live Theater" },
-       {    59, "Lodging" },
-       {    20, "Man Overboard" },
-       {     0, "Marina" },
-       {    43, "Medical Facility" },
-       {    66, "Mile Marker" },
-       {   101, "Military" },
-       {    60, "Mine" },
-       {    79, "Movie Theater" },
-       {    80, "Museum" },
-       {    21, "Navaid, Amber" },
-       {    22, "Navaid, Black" },
-       {    23, "Navaid, Blue" },
-       {    24, "Navaid, Green" },
-       {    25, "Navaid, Green/Red" },
-       {    26, "Navaid, Green/White" },
-       {    27, "Navaid, Orange" },
-       {    28, "Navaid, Red" },
-       {    29, "Navaid, Red/Green" },
-       {    30, "Navaid, Red/White" },
-       {    31, "Navaid, Violet" },
-       {    32, "Navaid, White" },
-       {    33, "Navaid, White/Green" },
-       {    34, "Navaid, White/Red" },
-       {   102, "Oil Field" },
-       {   115, "Parachute Area" },
-       {    46, "Park" },
-       {    45, "Parking Area" },
-       {    81, "Pharmacy" },
-       {    47, "Picnic Area" },
-       {    82, "Pizza" },
-       {    83, "Post Office" },
-       {   109, "Private Field" },
-       {    36, "Radio Beacon" },
-       {     3, "Red Diamond" },
-       {    16, "Red Square" },
-       {    10, "Residence" },
-       {    11, "Restaurant" },
-       {    54, "Restricted Area" },
-       {    39, "Restroom" },
-       {    84, "RV Park" },
-       {    91, "Scales" },
-       {    48, "Scenic Area" },
-       {    85, "School" },
-       {   116, "Seaplane Base" },
-       {    19, "Shipwreck" },
-       {    58, "Shopping Center" },
-       {   112, "Short Tower" },
-       {    40, "Shower" },
-       {    49, "Skiing Area" },
-       {    14, "Skull and Crossbones" },
-       {   110, "Soft Field" },
-       {    86, "Stadium" },
-       {   106, "Summit" },
-       {    50, "Swimming Area" },
-       {   111, "Tall Tower" },
-       {    42, "Telephone" },
-       {    92, "Toll Booth" },
-       {    67, "TracBack Point" },
-       {    61, "Trail Head" },
-       {    62, "Truck Stop" },
-       {   103, "Tunnel" },
-       {   114, "Ultralight Area" },
-       {    18, "Waypoint" },
-       {    17, "White Buoy" },
-       {    35, "White Dot" },
-       {    88, "Zoo" },
-       { -1, NULL },
-};
-
 char *snlen;
 
 static
@@ -204,20 +57,30 @@ arglist_t mps_args[] = {
 };
 
 const char *
-mps_find_desc_from_icon_number(const int icon)
+mps_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format)
 {
        icon_mapping_t *i;
 
        for (i = icon_table; i->icon; i++) {
-               if (icon == i->symnum) {
-                       return i->icon;
+               switch (garmin_format) {
+                       case MAPSOURCE:
+                               if (icon == i->mpssymnum)
+                                       return i->icon;
+                               break;
+                       case PCX:
+                       case GARMIN_SERIAL:
+                               if (icon == i->pcxsymnum)
+                                       return i->icon;
+                               break;
+                       default:
+                               fatal(MYNAME ": unknown garmin format");
                }
        }
        return "Waypoint";
 }
 
 int
-mps_find_icon_number_from_desc(const char *desc)
+mps_find_icon_number_from_desc(const char *desc, garmin_formats_e garmin_format)
 {
        icon_mapping_t *i;
        int def_icon = 18;
@@ -227,7 +90,15 @@ mps_find_icon_number_from_desc(const char *desc)
 
        for (i = icon_table; i->icon; i++) {
                if (case_ignore_strcmp(desc,i->icon) == 0) {
-                       return i->symnum;
+                       switch (garmin_format) {
+                       case MAPSOURCE:
+                               return i->mpssymnum;
+                       case PCX:
+                       case GARMIN_SERIAL:
+                               return i->pcxsymnum;
+                       default:
+                               fatal(MYNAME ": unknown garmin format");
+                       }
                }
        }
        return def_icon;
@@ -339,7 +210,7 @@ mps_read(void)
                wpt->description = xstrdup(wptdesc);
                wpt->position.latitude.degrees = lat / 2147483648.0 * 180.0;
                wpt->position.longitude.degrees = lon / 2147483648.0 * 180.0;
-               wpt->icon_descr = mps_find_desc_from_icon_number(icon);
+               wpt->icon_descr = mps_find_desc_from_icon_number(icon, MAPSOURCE);
                waypt_add(wpt);
 
 #ifdef DUMP_ICON_TABLE
@@ -376,10 +247,10 @@ mps_waypt_pr(const waypoint *wpt)
        memset(zbuf, 0, sizeof(zbuf));
        memset(ffbuf, 0xff, sizeof(ffbuf));
 
-       icon = mps_find_icon_number_from_desc(wpt->icon_descr);
+       icon = mps_find_icon_number_from_desc(wpt->icon_descr, MAPSOURCE);
 
        if (get_cache_icon(wpt)) {
-               icon = mps_find_icon_number_from_desc(get_cache_icon(wpt));
+               icon = mps_find_icon_number_from_desc(get_cache_icon(wpt), MAPSOURCE);
        }
 
        le_write32(&reclen, reclen);
index 04d65838a105f5d808b36d66783cfdb21dedee1a..56973a0ff60c155bd07c59f72367ca17030f601c 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "defs.h"
+#include "garmin_tables.h"
 #include <ctype.h>
 
 static FILE *file_in;
@@ -71,26 +72,30 @@ wr_deinit(void)
 static void
 data_read(void)
 {
-       char name[9], desc[90];
+       char name[7], desc[40];
        double lat,lon;
        char latdir, londir;
        long alt; 
+       int symnum;
        char alttype;
        char date[10];
        char time[9];
        waypoint *wpt_tmp;
-       char ibuf[100];
+       char ibuf[122];
 
        for(;fgets(ibuf, sizeof(ibuf), file_in);) {
                switch (ibuf[0]) {
                        case 'W': 
-                       sscanf(ibuf, "W  %s %c%lf %c%lf %s %s %ld %90[^\n']", 
+                       sscanf(ibuf, "W  %6c %c%lf %c%lf %s %s %ld %40c %*13c %d", 
                                name, &latdir, &lat, &londir, &lon, 
-                               date, time, &alt, desc);
+                               date, time, &alt, desc, &symnum);
+               desc[sizeof(desc)-1] = '\0';
+               name[sizeof(name)-1] = '\0';
                wpt_tmp = xcalloc(sizeof(*wpt_tmp), 1);
                wpt_tmp->position.altitude.altitude_meters = alt;
                wpt_tmp->shortname = xstrdup(name);
                wpt_tmp->description = xstrdup(desc);
+               wpt_tmp->icon_descr = mps_find_desc_from_icon_number(symnum, PCX);
 
                if (latdir == 'S') lat = -lat;
                if (londir == 'W') lon = -lon;
@@ -124,9 +129,9 @@ gpsutil_disp(const waypoint *wpt)
                tp++;
        }
 
-       icon_token = mps_find_icon_number_from_desc(deficon);
+       icon_token = mps_find_icon_number_from_desc(wpt->icon_descr, PCX);
        if (get_cache_icon(wpt)) {
-               icon_token = mps_find_icon_number_from_desc(get_cache_icon(wpt));
+               icon_token = mps_find_icon_number_from_desc(get_cache_icon(wpt), PCX);
        }